import { message } from 'antd';
export default {
  formatDate : (time) => {
    if (!time)
      return;

    let date    = new Date(time),
        year    = date.getFullYear(),
        month   = date.getMonth() + 1,
        day     = date.getDate(),
        h       = date.getHours(),
        m       = date.getMinutes(),
        s       = date.getSeconds();
    return `${year}-${month < 10 ? `0${month}` : month}-${day < 10 ? `0${day}` : day} ${h < 10 ? `0${h}` : h}:${m < 10 ? `0${m}` : m}:${s < 10 ? `0${s}` : s}`;
  },

  antMessage : (type='success', msg='') => {
    message.destroy();
    !!msg ? message[type](msg) : 0;
  },

  // data type
  dataType: (obj) => {
    return Object.prototype.toString.call(obj);
  }
}